fix: fallback dock theme to system settings on wayland#1605
Conversation
Reviewer's GuideRefactors Wayland dock wallpaper color handling by disabling WallpaperColorManager initialization on Wayland, extracting it into a dedicated initializer, and wiring the dock’s color theme to DGuiApplicationHelper’s themeTypeChanged signal so that on Wayland the dock falls back to system theme colors when wallpaper-based colors are unavailable. Sequence diagram for dock theme fallback to system settings on WaylandsequenceDiagram
participant DGuiApplicationHelper
participant DockPanel
participant WaylandDockHelper
participant WallpaperColorManager
Note over DockPanel,WaylandDockHelper: Wayland platform
alt [wallpaper color available]
DockPanel->>WaylandDockHelper: initWallpaperColorManager()
WaylandDockHelper->>WallpaperColorManager: watchScreen(dockScreenName())
WallpaperColorManager-->>DockPanel: activeChanged
DockPanel->>DockPanel: setColorTheme(ColorTheme_from_wallpaper)
else [wallpaper color unavailable]
DGuiApplicationHelper-->>DockPanel: themeTypeChanged
DockPanel->>DockPanel: setColorTheme(ColorTheme_from_themeType)
end
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- The new
initWallpaperColorManager()helper is currently unused; consider either wiring it behind a clear feature flag or removing it for now to avoid dead code and keep the Wayland path easier to reason about. - In
DockPanel::init()on Wayland, thethemeTypeChangedconnection is created unconditionally; ifinit()can be called more than once, consider usingQt::UniqueConnectionor moving this connection to the constructor to avoid accumulating duplicate connections.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The new `initWallpaperColorManager()` helper is currently unused; consider either wiring it behind a clear feature flag or removing it for now to avoid dead code and keep the Wayland path easier to reason about.
- In `DockPanel::init()` on Wayland, the `themeTypeChanged` connection is created unconditionally; if `init()` can be called more than once, consider using `Qt::UniqueConnection` or moving this connection to the constructor to avoid accumulating duplicate connections.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: 18202781743, BLumia The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
1. Disable WallpaperColorManager initialization in WaylandDockHelper constructor 2. Extract wallpaper color management to a separate initWallpaperColorManager() method 3. Connect dock theme changes to DGuiApplicationHelper themeTypeChanged signal on Wayland 4. This ensures dock follows system theme when wallpaper color is unavailable Log: Dock theme on Wayland now falls back to system color settings Influence: 1. Test dock color theme toggling between light and dark on Wayland 2. Verify dock theme syncs with system settings after change 3. Ensure no regression in dock color behavior on X11 4. Check that wallpaper color feature is cleanly disabled without errors 5. Verify dock screen changes don't trigger wallpaper color manager calls fix: wayland下dock暗亮色回退到系统设置 1. 禁用WaylandDockHelper构造函数中的WallpaperColorManager初始化 2. 将壁纸颜色管理提取到独立的initWallpaperColorManager()方法中 3. 在Wayland上连接dock主题变化到DGuiApplicationHelper的themeTypeChanged 信号 4. 确保壁纸颜色不可用时dock遵循系统主题 Log: Wayland下Dock主题现在回退到系统颜色设置 Influence: 1. 在Wayland上测试dock颜色主题在亮色和暗色间切换 2. 验证dock主题在系统设置更改后同步 3. 确保X11上dock颜色行为无回归 4. 检查壁纸颜色功能被干净禁用,无错误产生 5. 验证dock屏幕变化不会触发壁纸颜色管理器调用 PMS: BUG-344841
deepin pr auto review你好!我是CodeGeeX,你的智能编程助手。我已经仔细审查了你提供的Git Diff代码。 这次代码变更的主要目的是:将Wayland环境下的壁纸颜色管理器( 整体思路上没有严重的逻辑错误,但在代码质量、性能和安全性方面,有一些值得注意和改进的地方。以下是详细的审查意见: 1. 语法与逻辑
2. 代码质量
3. 代码性能
4. 代码安全
💡 综合改进建议代码示例基于以上分析,我为你提供一份优化后的代码参考: panels/dock/dockpanel.cpp bool DockPanel::init()
{
m_theme = static_cast<ColorTheme>(Dtk::Gui::DGuiApplicationHelper::instance()->themeType());
auto platformName = QGuiApplication::platformName();
if (QStringLiteral("wayland") == platformName) {
m_helper = new WaylandDockHelper(this);
- // Fallback to DGuiApplicationHelper for theme color when wayland wallpaper color is not available.
- // TODO: remove this when initWallpaperColorManager is re-enabled
- QObject::connect(Dtk::Gui::DGuiApplicationHelper::instance(), &Dtk::Gui::DGuiApplicationHelper::themeTypeChanged,
- this, [this]() {
- setColorTheme(static_cast<ColorTheme>(Dtk::Gui::DGuiApplicationHelper::instance()->themeType()));
- });
} else if (QStringLiteral("xcb") == platformName) {
- QObject::connect(Dtk::Gui::DGuiApplicationHelper::instance(), &Dtk::Gui::DGuiApplicationHelper::themeTypeChanged,
- this, [this](){
- setColorTheme(static_cast<ColorTheme>(Dtk::Gui::DGuiApplicationHelper::instance()->themeType()));
- });
+ // XCB 分支无需额外处理,统一在外部处理主题变更
}
+
+ // Fallback to DGuiApplicationHelper for theme color when wayland wallpaper color is not available.
+ // TODO: remove this when initWallpaperColorManager is re-enabled (due to Wayland color extraction API instability)
+ QObject::connect(Dtk::Gui::DGuiApplicationHelper::instance(), &Dtk::Gui::DGuiApplicationHelper::themeTypeChanged,
+ this, [this]() {
+ ColorTheme newTheme = static_cast<ColorTheme>(Dtk::Gui::DGuiApplicationHelper::instance()->themeType());
+ if (m_theme != newTheme) { // 性能优化:避免无意义的重复赋值和UI刷新
+ setColorTheme(newTheme);
+ }
+ });
+
// ... 其他代码 ...
}panels/dock/waylanddockhelper.cpp WaylandDockHelper::WaylandDockHelper(DockPanel *panel)
: m_isCurrentActiveWindowFullscreened(false)
, m_panel(panel)
{
m_ddeShellManager.reset(new TreeLandDDEShellManager());
DS_NAMESPACE::DAppletBridge bridge("org.deepin.ds.dock.taskmanager");
if (auto applet = bridge.applet()) {
// ...
}
- // 此处清理了多余的空行
connect(m_panel, &DockPanel::positionChanged, this, &WaylandDockHelper::updateOverlapCheckerPos);
connect(m_panel, &DockPanel::dockSizeChanged, this, &WaylandDockHelper::updateOverlapCheckerPos);
// ...
+ // TODO: 目前 Wayland 壁纸取色功能暂未稳定,暂不初始化 WallpaperColorManager
+ // initWallpaperColorManager();
}通过以上改进,代码的冗余度降低,性能更好,且对生命周期的管理更加安全明确。如果有任何其他问题,欢迎随时提问! |
constructor
initWallpaperColorManager() method
signal on Wayland
unavailable
Log: Dock theme on Wayland now falls back to system color settings
Influence:
calls
fix: wayland下dock暗亮色回退到系统设置
信号
Log: Wayland下Dock主题现在回退到系统颜色设置
Influence:
PMS: BUG-344841
Summary by Sourcery
Make the Wayland dock fall back to system theme settings when wallpaper-based colors are unavailable.
Bug Fixes:
Enhancements: